import Vue from "vue";
import store from "@/store";
import "./filter";
import "./directive";
import "./dom";
//
import {
  Alert,
  Autocomplete,
  Avatar,
  Breadcrumb,
  BreadcrumbItem,
  Button,
  Carousel,
  CarouselItem,
  Checkbox,
  CheckboxGroup,
  Col,
  ColorPicker,
  DatePicker,
  Dialog,
  Dropdown,
  DropdownItem,
  DropdownMenu,
  Form,
  FormItem,
  Image,
  InfiniteScroll,
  Input,
  InputNumber,
  Loading,
  Menu,
  MenuItem,
  MenuItemGroup,
  Message,
  MessageBox,
  Notification,
  Option,
  Pagination,
  Popover,
  Progress,
  Radio,
  RadioButton,
  RadioGroup,
  Row,
  Select,
  Slider,
  Submenu,
  Switch,
  Table,
  TableColumn,
  TabPane,
  Tabs,
  Tag,
  Timeline,
  TimelineItem,
  TimePicker,
  Tooltip,
  Tree,
  Badge,
  Upload
} from "element-ui";


Vue.use(Badge);
Vue.use(Avatar);
Vue.use(Menu);
Vue.use(MenuItem);
Vue.use(Submenu);
Vue.use(MenuItemGroup);
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Popover);
Vue.use(Tag);
Vue.use(Row);
Vue.use(Timeline);
Vue.use(TimelineItem);
Vue.use(InputNumber);
Vue.use(InfiniteScroll);
Vue.use(Progress);
Vue.use(Autocomplete);
Vue.use(Input);
Vue.use(Button);
Vue.use(Pagination);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Loading.directive);
Vue.use(Radio);
Vue.use(Dialog);
Vue.use(Form);
Vue.use(Alert);
Vue.use(FormItem);
Vue.use(Upload);
Vue.use(Select);
Vue.use(Option);
Vue.use(RadioGroup);
Vue.use(RadioButton);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Tree);
Vue.use(Tooltip);
Vue.use(Switch);
Vue.use(Carousel);
Vue.use(CarouselItem);
Vue.use(TimePicker);
Vue.use(Col);
Vue.use(DatePicker);
Vue.use(CheckboxGroup);
Vue.use(Checkbox);
Vue.use(ColorPicker);
Vue.use(Slider);
Vue.use(TableColumn);
Vue.use(Table);
Vue.use(Image);

export const fun = {
  msgbox: MessageBox,
  message(arg: any) {
    let options = { message: "" };
    if (!arg) return;
    if (typeof arg === "string") {
      options = { message: arg };
    } else {
      options = { ...arg };
    }
    Message(options);
  },
  loading(arg: any) {
    let options = {};
    if (!arg) arg = "loading";
    if (typeof arg === "string") {
      options = { text: arg };
    } else {
      options = { text: "loading", ...arg };
    }

    console.log(options);

    //不是pc就不要遮盖了
    return Loading.service({
      ...options,
      background: store.getters.getDevice() === "pc" ? "" : "rgba(0,0,0,0)"
    });
  },
  success: ({ msg = "操作成功", title = "成功" }) =>
    Notification({
      title,
      message: msg,
      type: "success"
    }),
  warning: ({ msg = "", title = "警告" }) =>
    Notification({
      title,
      message: msg,
      type: "warning"
    }),
  info: ({ msg = "", title = "提示" }) =>
    Notification({
      title,
      message: msg,
      type: "info"
    }),
  error: ({ msg = "错误", title = "错误" }) =>
    Notification({
      title,
      message: msg,
      type: "error"
    }),
  alert: ({ msg = "", options = {} }) => MessageBox.alert(msg, options),
  prompt: ({ msg = "", title = "提示", options = {} }) =>
    MessageBox.prompt(msg, title, options),
  confirm: ({ msg = "", title = "提示", options = {} }) =>
    MessageBox.confirm(msg, title, options)
};
// console.log(filter)
